home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl / 5.10.0 / ExtUtils / Liblist / Kid.pm
Encoding:
Perl POD Document  |  2009-06-26  |  18.6 KB  |  550 lines

  1. package ExtUtils::Liblist::Kid;
  2.  
  3. # XXX Splitting this out into its own .pm is a temporary solution.
  4.  
  5. # This kid package is to be used by MakeMaker.  It will not work if
  6. # $self is not a Makemaker.
  7.  
  8. use 5.00503;
  9. # Broken out of MakeMaker from version 4.11
  10.  
  11. use strict;
  12. use vars qw($VERSION);
  13. $VERSION = 6.42;
  14.  
  15. use Config;
  16. use Cwd 'cwd';
  17. use File::Basename;
  18. use File::Spec;
  19.  
  20. sub ext {
  21.   if   ($^O eq 'VMS')     { return &_vms_ext;      }
  22.   elsif($^O eq 'MSWin32') { return &_win32_ext;    }
  23.   else                    { return &_unix_os2_ext; }
  24. }
  25.  
  26. sub _unix_os2_ext {
  27.     my($self,$potential_libs, $verbose, $give_libs) = @_;
  28.     $verbose ||= 0;
  29.  
  30.     if ($^O =~ 'os2' and $Config{perllibs}) { 
  31.     # Dynamic libraries are not transitive, so we may need including
  32.     # the libraries linked against perl.dll again.
  33.  
  34.     $potential_libs .= " " if $potential_libs;
  35.     $potential_libs .= $Config{perllibs};
  36.     }
  37.     return ("", "", "", "", ($give_libs ? [] : ())) unless $potential_libs;
  38.     warn "Potential libraries are '$potential_libs':\n" if $verbose;
  39.  
  40.     my($so)   = $Config{so};
  41.     my($libs) = defined $Config{perllibs} ? $Config{perllibs} : $Config{libs};
  42.     my $Config_libext = $Config{lib_ext} || ".a";
  43.  
  44.  
  45.     # compute $extralibs, $bsloadlibs and $ldloadlibs from
  46.     # $potential_libs
  47.     # this is a rewrite of Andy Dougherty's extliblist in perl
  48.  
  49.     my(@searchpath); # from "-L/path" entries in $potential_libs
  50.     my(@libpath) = split " ", $Config{'libpth'};
  51.     my(@ldloadlibs, @bsloadlibs, @extralibs, @ld_run_path, %ld_run_path_seen);
  52.     my(@libs, %libs_seen);
  53.     my($fullname, $thislib, $thispth, @fullname);
  54.     my($pwd) = cwd(); # from Cwd.pm
  55.     my($found) = 0;
  56.  
  57.     # Debian-specific: don't use LD_RUN_PATH for standard dirs
  58.     $ld_run_path_seen{$_}++ for qw(/lib /usr/lib /usr/X11R6/lib);
  59.  
  60.     foreach $thislib (split ' ', $potential_libs){
  61.  
  62.     # Handle possible linker path arguments.
  63.     if ($thislib =~ s/^(-[LR]|-Wl,-R)//){    # save path flag type
  64.         my($ptype) = $1;
  65.         unless (-d $thislib){
  66.         warn "$ptype$thislib ignored, directory does not exist\n"
  67.             if $verbose;
  68.         next;
  69.         }
  70.         my($rtype) = $ptype;
  71.         if (($ptype eq '-R') or ($ptype eq '-Wl,-R')) {
  72.         if ($Config{'lddlflags'} =~ /-Wl,-R/) {
  73.             $rtype = '-Wl,-R';
  74.         } elsif ($Config{'lddlflags'} =~ /-R/) {
  75.             $rtype = '-R';
  76.         }
  77.         }
  78.         unless (File::Spec->file_name_is_absolute($thislib)) {
  79.           warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
  80.           $thislib = $self->catdir($pwd,$thislib);
  81.         }
  82.         push(@searchpath, $thislib);
  83.         push(@extralibs,  "$ptype$thislib");
  84.         push(@ldloadlibs, "$rtype$thislib");
  85.         next;
  86.     }
  87.  
  88.     # Handle possible library arguments.
  89.     unless ($thislib =~ s/^-l//){
  90.       warn "Unrecognized argument in LIBS ignored: '$thislib'\n";
  91.       next;
  92.     }
  93.  
  94.     my($found_lib)=0;
  95.     foreach $thispth (@searchpath, @libpath){
  96.  
  97.         # Try to find the full name of the library.  We need this to
  98.         # determine whether it's a dynamically-loadable library or not.
  99.         # This tends to be subject to various os-specific quirks.
  100.         # For gcc-2.6.2 on linux (March 1995), DLD can not load
  101.         # .sa libraries, with the exception of libm.sa, so we
  102.         # deliberately skip them.
  103.         if (@fullname =
  104.             $self->lsdir($thispth,"^\Qlib$thislib.$so.\E[0-9]+")){
  105.         # Take care that libfoo.so.10 wins against libfoo.so.9.
  106.         # Compare two libraries to find the most recent version
  107.         # number.  E.g.  if you have libfoo.so.9.0.7 and
  108.         # libfoo.so.10.1, first convert all digits into two
  109.         # decimal places.  Then we'll add ".00" to the shorter
  110.         # strings so that we're comparing strings of equal length
  111.         # Thus we'll compare libfoo.so.09.07.00 with
  112.         # libfoo.so.10.01.00.  Some libraries might have letters
  113.         # in the version.  We don't know what they mean, but will
  114.         # try to skip them gracefully -- we'll set any letter to
  115.         # '0'.  Finally, sort in reverse so we can take the
  116.         # first element.
  117.  
  118.         #TODO: iterate through the directory instead of sorting
  119.  
  120.         $fullname = "$thispth/" .
  121.         (sort { my($ma) = $a;
  122.             my($mb) = $b;
  123.             $ma =~ tr/A-Za-z/0/s;
  124.             $ma =~ s/\b(\d)\b/0$1/g;
  125.             $mb =~ tr/A-Za-z/0/s;
  126.             $mb =~ s/\b(\d)\b/0$1/g;
  127.             while (length($ma) < length($mb)) { $ma .= ".00"; }
  128.             while (length($mb) < length($ma)) { $mb .= ".00"; }
  129.             # Comparison deliberately backwards
  130.             $mb cmp $ma;} @fullname)[0];
  131.         } elsif (-f ($fullname="$thispth/lib$thislib.$so")
  132.          && (($Config{'dlsrc'} ne "dl_dld.xs") || ($thislib eq "m"))){
  133.         } elsif (-f ($fullname="$thispth/lib${thislib}_s$Config_libext")
  134.                  && (! $Config{'archname'} =~ /RM\d\d\d-svr4/)
  135.          && ($thislib .= "_s") ){ # we must explicitly use _s version
  136.         } elsif (-f ($fullname="$thispth/lib$thislib$Config_libext")){
  137.         } elsif (-f ($fullname="$thispth/$thislib$Config_libext")){
  138.             } elsif (-f ($fullname="$thispth/lib$thislib.dll$Config_libext")){
  139.         } elsif (-f ($fullname="$thispth/Slib$thislib$Config_libext")){
  140.         } elsif ($^O eq 'dgux'
  141.          && -l ($fullname="$thispth/lib$thislib$Config_libext")
  142.          && readlink($fullname) =~ /^elink:/s) {
  143.          # Some of DG's libraries look like misconnected symbolic
  144.          # links, but development tools can follow them.  (They
  145.          # look like this:
  146.          #
  147.          #    libm.a -> elink:${SDE_PATH:-/usr}/sde/\
  148.          #    ${TARGET_BINARY_INTERFACE:-m88kdgux}/usr/lib/libm.a
  149.          #
  150.          # , the compilation tools expand the environment variables.)
  151.         } else {
  152.         warn "$thislib not found in $thispth\n" if $verbose;
  153.         next;
  154.         }
  155.         warn "'-l$thislib' found at $fullname\n" if $verbose;
  156.         push @libs, $fullname unless $libs_seen{$fullname}++;
  157.         $found++;
  158.         $found_lib++;
  159.  
  160.         # Now update library lists
  161.  
  162.         # what do we know about this library...
  163.         my $is_dyna = ($fullname !~ /\Q$Config_libext\E\z/);
  164.         my $in_perl = ($libs =~ /\B-l\Q${thislib}\E\b/s);
  165.  
  166.             # include the path to the lib once in the dynamic linker path
  167.             # but only if it is a dynamic lib and not in Perl itself
  168.             my($fullnamedir) = dirname($fullname);
  169.             push @ld_run_path, $fullnamedir
  170.                  if $is_dyna && !$in_perl &&
  171.                     !$ld_run_path_seen{$fullnamedir}++;
  172.  
  173.         # Do not add it into the list if it is already linked in
  174.         # with the main perl executable.
  175.         # We have to special-case the NeXT, because math and ndbm 
  176.         # are both in libsys_s
  177.         unless ($in_perl || 
  178.         ($Config{'osname'} eq 'next' &&
  179.             ($thislib eq 'm' || $thislib eq 'ndbm')) ){
  180.         push(@extralibs, "-l$thislib");
  181.         }
  182.  
  183.         # We might be able to load this archive file dynamically
  184.         if ( ($Config{'dlsrc'} =~ /dl_next/ && $Config{'osvers'} lt '4_0')
  185.         ||   ($Config{'dlsrc'} =~ /dl_dld/) )
  186.         {
  187.         # We push -l$thislib instead of $fullname because
  188.         # it avoids hardwiring a fixed path into the .bs file.
  189.         # Mkbootstrap will automatically add dl_findfile() to
  190.         # the .bs file if it sees a name in the -l format.
  191.         # USE THIS, when dl_findfile() is fixed: 
  192.         # push(@bsloadlibs, "-l$thislib");
  193.         # OLD USE WAS while checking results against old_extliblist
  194.         push(@bsloadlibs, "$fullname");
  195.         } else {
  196.         if ($is_dyna){
  197.                     # For SunOS4, do not add in this shared library if
  198.                     # it is already linked in the main perl executable
  199.             push(@ldloadlibs, "-l$thislib")
  200.             unless ($in_perl and $^O eq 'sunos');
  201.         } else {
  202.             push(@ldloadlibs, "-l$thislib");
  203.         }
  204.         }
  205.         last;    # found one here so don't bother looking further
  206.     }
  207.     warn "Note (probably harmless): "
  208.              ."No library found for -l$thislib\n"
  209.         unless $found_lib>0;
  210.     }
  211.  
  212.     unless( $found ) {
  213.         return ('','','','', ($give_libs ? \@libs : ()));
  214.     }
  215.     else {
  216.         return ("@extralibs", "@bsloadlibs", "@ldloadlibs",
  217.                 join(":",@ld_run_path), ($give_libs ? \@libs : ()));
  218.     }
  219. }
  220.  
  221. sub _win32_ext {
  222.  
  223.     require Text::ParseWords;
  224.  
  225.     my($self, $potential_libs, $verbose, $give_libs) = @_;
  226.     $verbose ||= 0;
  227.  
  228.     # If user did not supply a list, we punt.
  229.     # (caller should probably use the list in $Config{libs})
  230.     return ("", "", "", "", ($give_libs ? [] : ())) unless $potential_libs;
  231.  
  232.     my $cc        = $Config{cc};
  233.     my $VC        = $cc =~ /^cl/i;
  234.     my $BC        = $cc =~ /^bcc/i;
  235.     my $GC        = $cc =~ /^gcc/i;
  236.     my $so        = $Config{'so'};
  237.     my $libs        = $Config{'perllibs'};
  238.     my $libpth        = $Config{'libpth'};
  239.     my $libext        = $Config{'lib_ext'} || ".lib";
  240.     my(@libs, %libs_seen);
  241.  
  242.     if ($libs and $potential_libs !~ /:nodefault/i) { 
  243.     # If Config.pm defines a set of default libs, we always
  244.     # tack them on to the user-supplied list, unless the user
  245.     # specified :nodefault
  246.  
  247.     $potential_libs .= " " if $potential_libs;
  248.     $potential_libs .= $libs;
  249.     }
  250.     warn "Potential libraries are '$potential_libs':\n" if $verbose;
  251.  
  252.     # normalize to forward slashes
  253.     $libpth =~ s,\\,/,g;
  254.     $potential_libs =~ s,\\,/,g;
  255.  
  256.     # compute $extralibs from $potential_libs
  257.  
  258.     my @searchpath;            # from "-L/path" in $potential_libs
  259.     my @libpath        = Text::ParseWords::quotewords('\s+', 0, $libpth);
  260.     my @extralibs;
  261.     my $pwd        = cwd();    # from Cwd.pm
  262.     my $lib        = '';
  263.     my $found        = 0;
  264.     my $search        = 1;
  265.     my($fullname, $thislib, $thispth);
  266.  
  267.     # add "$Config{installarchlib}/CORE" to default search path
  268.     push @libpath, "$Config{installarchlib}/CORE";
  269.  
  270.     if ($VC and exists $ENV{LIB} and $ENV{LIB}) {
  271.         push @libpath, split /;/, $ENV{LIB};
  272.     }
  273.  
  274.     foreach (Text::ParseWords::quotewords('\s+', 0, $potential_libs)){
  275.  
  276.     $thislib = $_;
  277.  
  278.         # see if entry is a flag
  279.     if (/^:\w+$/) {
  280.         $search    = 0 if lc eq ':nosearch';
  281.         $search    = 1 if lc eq ':search';
  282.         warn "Ignoring unknown flag '$thislib'\n"
  283.         if $verbose and !/^:(no)?(search|default)$/i;
  284.         next;
  285.     }
  286.  
  287.     # if searching is disabled, do compiler-specific translations
  288.     unless ($search) {
  289.         s/^-l(.+)$/$1.lib/ unless $GC;
  290.         s/^-L/-libpath:/ if $VC;
  291.         push(@extralibs, $_);
  292.         $found++;
  293.         next;
  294.     }
  295.  
  296.     # handle possible linker path arguments
  297.     if (s/^-L// and not -d) {
  298.         warn "$thislib ignored, directory does not exist\n"
  299.         if $verbose;
  300.         next;
  301.     }
  302.     elsif (-d) {
  303.         unless (File::Spec->file_name_is_absolute($_)) {
  304.           warn "Warning: '$thislib' changed to '-L$pwd/$_'\n";
  305.           $_ = $self->catdir($pwd,$_);
  306.         }
  307.         push(@searchpath, $_);
  308.         next;
  309.     }
  310.  
  311.     # handle possible library arguments
  312.     if (s/^-l// and $GC and !/^lib/i) {
  313.         $_ = "lib$_";
  314.     }
  315.     $_ .= $libext if !/\Q$libext\E$/i;
  316.  
  317.     my $secondpass = 0;
  318.     LOOKAGAIN:
  319.  
  320.         # look for the file itself
  321.     if (-f) {
  322.         warn "'$thislib' found as '$_'\n" if $verbose;
  323.         $found++;
  324.         push(@extralibs, $_);
  325.         next;
  326.     }
  327.  
  328.     my $found_lib = 0;
  329.     foreach $thispth (@searchpath, @libpath){
  330.         unless (-f ($fullname="$thispth\\$_")) {
  331.         warn "'$thislib' not found as '$fullname'\n" if $verbose;
  332.         next;
  333.         }
  334.         warn "'$thislib' found as '$fullname'\n" if $verbose;
  335.         $found++;
  336.         $found_lib++;
  337.         push(@extralibs, $fullname);
  338.         push @libs, $fullname unless $libs_seen{$fullname}++;
  339.         last;
  340.     }
  341.  
  342.     # do another pass with (or without) leading 'lib' if they used -l
  343.     if (!$found_lib and $thislib =~ /^-l/ and !$secondpass++) {
  344.         if ($GC) {
  345.         goto LOOKAGAIN if s/^lib//i;
  346.         }
  347.         elsif (!/^lib/i) {
  348.         $_ = "lib$_";
  349.         goto LOOKAGAIN;
  350.         }
  351.     }
  352.  
  353.     # give up
  354.     warn "Note (probably harmless): "
  355.              ."No library found for $thislib\n"
  356.         unless $found_lib>0;
  357.  
  358.     }
  359.  
  360.     return ('','','','', ($give_libs ? \@libs : ())) unless $found;
  361.  
  362.     # make sure paths with spaces are properly quoted
  363.     @extralibs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @extralibs;
  364.     @libs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @libs;
  365.     $lib = join(' ',@extralibs);
  366.  
  367.     # normalize back to backward slashes (to help braindead tools)
  368.     # XXX this may break equally braindead GNU tools that don't understand
  369.     # backslashes, either.  Seems like one can't win here.  Cursed be CP/M.
  370.     $lib =~ s,/,\\,g;
  371.  
  372.     warn "Result: $lib\n" if $verbose;
  373.     wantarray ? ($lib, '', $lib, '', ($give_libs ? \@libs : ())) : $lib;
  374. }
  375.  
  376.  
  377. sub _vms_ext {
  378.   my($self, $potential_libs,$verbose,$give_libs) = @_;
  379.   $verbose ||= 0;
  380.  
  381.   my(@crtls,$crtlstr);
  382.   @crtls = ( ($Config{'ldflags'} =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
  383.               . 'PerlShr/Share' );
  384.   push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
  385.   push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
  386.   # In general, we pass through the basic libraries from %Config unchanged.
  387.   # The one exception is that if we're building in the Perl source tree, and
  388.   # a library spec could be resolved via a logical name, we go to some trouble
  389.   # to insure that the copy in the local tree is used, rather than one to
  390.   # which a system-wide logical may point.
  391.   if ($self->{PERL_SRC}) {
  392.     my($lib,$locspec,$type);
  393.     foreach $lib (@crtls) { 
  394.       if (($locspec,$type) = $lib =~ m{^([\w\$-]+)(/\w+)?} and $locspec =~ /perl/i) {
  395.         if    (lc $type eq '/share')   { $locspec .= $Config{'exe_ext'}; }
  396.         elsif (lc $type eq '/library') { $locspec .= $Config{'lib_ext'}; }
  397.         else                           { $locspec .= $Config{'obj_ext'}; }
  398.         $locspec = $self->catfile($self->{PERL_SRC},$locspec);
  399.         $lib = "$locspec$type" if -e $locspec;
  400.       }
  401.     }
  402.   }
  403.   $crtlstr = @crtls ? join(' ',@crtls) : '';
  404.  
  405.   unless ($potential_libs) {
  406.     warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose;
  407.     return ('', '', $crtlstr, '', ($give_libs ? [] : ()));
  408.   }
  409.  
  410.   my(@dirs,@libs,$dir,$lib,%found,@fndlibs,$ldlib);
  411.   my $cwd = cwd();
  412.   my($so,$lib_ext,$obj_ext) = @Config{'so','lib_ext','obj_ext'};
  413.   # List of common Unix library names and their VMS equivalents
  414.   # (VMS equivalent of '' indicates that the library is automatically
  415.   # searched by the linker, and should be skipped here.)
  416.   my(@flibs, %libs_seen);
  417.   my %libmap = ( 'm' => '', 'f77' => '', 'F77' => '', 'V77' => '', 'c' => '',
  418.                  'malloc' => '', 'crypt' => '', 'resolv' => '', 'c_s' => '',
  419.                  'socket' => '', 'X11' => 'DECW$XLIBSHR',
  420.                  'Xt' => 'DECW$XTSHR', 'Xm' => 'DECW$XMLIBSHR',
  421.                  'Xmu' => 'DECW$XMULIBSHR');
  422.   if ($Config{'vms_cc_type'} ne 'decc') { $libmap{'curses'} = 'VAXCCURSE'; }
  423.  
  424.   warn "Potential libraries are '$potential_libs'\n" if $verbose;
  425.  
  426.   # First, sort out directories and library names in the input
  427.   foreach $lib (split ' ',$potential_libs) {
  428.     push(@dirs,$1),   next if $lib =~ /^-L(.*)/;
  429.     push(@dirs,$lib), next if $lib =~ /[:>\]]$/;
  430.     push(@dirs,$lib), next if -d $lib;
  431.     push(@libs,$1),   next if $lib =~ /^-l(.*)/;
  432.     push(@libs,$lib);
  433.   }
  434.   push(@dirs,split(' ',$Config{'libpth'}));
  435.  
  436.   # Now make sure we've got VMS-syntax absolute directory specs
  437.   # (We don't, however, check whether someone's hidden a relative
  438.   # path in a logical name.)
  439.   foreach $dir (@dirs) {
  440.     unless (-d $dir) {
  441.       warn "Skipping nonexistent Directory $dir\n" if $verbose > 1;
  442.       $dir = '';
  443.       next;
  444.     }
  445.     warn "Resolving directory $dir\n" if $verbose;
  446.     if (File::Spec->file_name_is_absolute($dir)) { 
  447.         $dir = $self->fixpath($dir,1); 
  448.     }
  449.     else { 
  450.         $dir = $self->catdir($cwd,$dir); 
  451.     }
  452.   }
  453.   @dirs = grep { length($_) } @dirs;
  454.   unshift(@dirs,''); # Check each $lib without additions first
  455.  
  456.   LIB: foreach $lib (@libs) {
  457.     if (exists $libmap{$lib}) {
  458.       next unless length $libmap{$lib};
  459.       $lib = $libmap{$lib};
  460.     }
  461.  
  462.     my(@variants,$variant,$cand);
  463.     my($ctype) = '';
  464.  
  465.     # If we don't have a file type, consider it a possibly abbreviated name and
  466.     # check for common variants.  We try these first to grab libraries before
  467.     # a like-named executable image (e.g. -lperl resolves to perlshr.exe
  468.     # before perl.exe).
  469.     if ($lib !~ /\.[^:>\]]*$/) {
  470.       push(@variants,"${lib}shr","${lib}rtl","${lib}lib");
  471.       push(@variants,"lib$lib") if $lib !~ /[:>\]]/;
  472.     }
  473.     push(@variants,$lib);
  474.     warn "Looking for $lib\n" if $verbose;
  475.     foreach $variant (@variants) {
  476.       my($fullname, $name);
  477.  
  478.       foreach $dir (@dirs) {
  479.         my($type);
  480.  
  481.         $name = "$dir$variant";
  482.         warn "\tChecking $name\n" if $verbose > 2;
  483.         $fullname = VMS::Filespec::rmsexpand($name);
  484.         if (defined $fullname and -f $fullname) {
  485.           # It's got its own suffix, so we'll have to figure out the type
  486.           if    ($fullname =~ /(?:$so|exe)$/i)      { $type = 'SHR'; }
  487.           elsif ($fullname =~ /(?:$lib_ext|olb)$/i) { $type = 'OLB'; }
  488.           elsif ($fullname =~ /(?:$obj_ext|obj)$/i) {
  489.             warn "Note (probably harmless): "
  490.                 ."Plain object file $fullname found in library list\n";
  491.             $type = 'OBJ';
  492.           }
  493.           else {
  494.             warn "Note (probably harmless): "
  495.                 ."Unknown library type for $fullname; assuming shared\n";
  496.             $type = 'SHR';
  497.           }
  498.         }
  499.         elsif (-f ($fullname = VMS::Filespec::rmsexpand($name,$so))      or
  500.                -f ($fullname = VMS::Filespec::rmsexpand($name,'.exe')))     {
  501.           $type = 'SHR';
  502.           $name = $fullname unless $fullname =~ /exe;?\d*$/i;
  503.         }
  504.         elsif (not length($ctype) and  # If we've got a lib already, 
  505.                                        # don't bother
  506.                ( -f ($fullname = VMS::Filespec::rmsexpand($name,$lib_ext)) or
  507.                  -f ($fullname = VMS::Filespec::rmsexpand($name,'.olb'))))  {
  508.           $type = 'OLB';
  509.           $name = $fullname unless $fullname =~ /olb;?\d*$/i;
  510.         }
  511.         elsif (not length($ctype) and  # If we've got a lib already, 
  512.                                        # don't bother
  513.                ( -f ($fullname = VMS::Filespec::rmsexpand($name,$obj_ext)) or
  514.                  -f ($fullname = VMS::Filespec::rmsexpand($name,'.obj'))))  {
  515.           warn "Note (probably harmless): "
  516.                ."Plain object file $fullname found in library list\n";
  517.           $type = 'OBJ';
  518.           $name = $fullname unless $fullname =~ /obj;?\d*$/i;
  519.         }
  520.         if (defined $type) {
  521.           $ctype = $type; $cand = $name;
  522.           last if $ctype eq 'SHR';
  523.         }
  524.       }
  525.       if ($ctype) { 
  526.         # This has to precede any other CRTLs, so just make it first
  527.         if ($cand eq 'VAXCCURSE') { unshift @{$found{$ctype}}, $cand; }  
  528.         else                      { push    @{$found{$ctype}}, $cand; }
  529.         warn "\tFound as $cand (really $fullname), type $ctype\n" 
  530.           if $verbose > 1;
  531.     push @flibs, $name unless $libs_seen{$fullname}++;
  532.         next LIB;
  533.       }
  534.     }
  535.     warn "Note (probably harmless): "
  536.          ."No library found for $lib\n";
  537.   }
  538.  
  539.   push @fndlibs, @{$found{OBJ}}                      if exists $found{OBJ};
  540.   push @fndlibs, map { "$_/Library" } @{$found{OLB}} if exists $found{OLB};
  541.   push @fndlibs, map { "$_/Share"   } @{$found{SHR}} if exists $found{SHR};
  542.   $lib = join(' ',@fndlibs);
  543.  
  544.   $ldlib = $crtlstr ? "$lib $crtlstr" : $lib;
  545.   warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose;
  546.   wantarray ? ($lib, '', $ldlib, '', ($give_libs ? \@flibs : ())) : $lib;
  547. }
  548.  
  549. 1;
  550.